<?php
require_once("../../connection.php");

$gp_mem = $_POST['gp_mem'];
$gpid = $_POST['gpid'];

//echo $gp_mem." ".$gpid;


//disseminating the user array
$arr = explode(";",$gp_mem);

foreach($arr as $mem)
{
	if($mem != "")
	{
	$temp = explode(':',$mem);
	//$mem_id = substr($temp[0],8);
	$mem_id = $temp[0];
	$mem_name = $temp[1];
	
	//echo $mem_id."--";

	if(mysql_num_rows(mysql_query("SELECT * FROM site_group_members WHERE `gpid`='$gpid' AND `fbid`='$mem_id' AND `del`!='1'")) == 0)
		{
			$res = mysql_query("INSERT INTO site_group_members (`gpid`,`fbid`,`username`,`mod`,`del`) VALUES ('$gpid','$mem_id','$mem_name','0','0')");
			if(!$res) echo mysql_error();	
		}
		else
			echo "That member already exists!";
	}
}
?>